from __future__ import annotations
from celery import Celery
from celery.schedules import crontab

from . import config as cfg

app = Celery(
    "weather_alert",
    broker=cfg.REDIS_URL,
    backend=cfg.REDIS_URL,
    include=["app.tasks"],
)

# 时区配置：按本地时区执行 crontab
app.conf.timezone = cfg.TIMEZONE
app.conf.enable_utc = False

# 定时任务：每天 7:00
app.conf.beat_schedule = {
    "daily-weather-reminder": {
        "task": "app.tasks.send_daily_weather",
        "schedule": crontab(hour=7, minute=0),
        "options": {"queue": "weather"},
    }
}